<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    img {
      width: 100px;
      height: 100px;
      margin-left: 100px;
      margin-top: 60px;
    }

    .boxs {
      width: 300px;
      height: 300px;
      background-color: antiquewhite;
      display: inline-block;
      margin-left: 170px;
    }

    .a1 {
      display: inline-block;
    }

    .a {
      margin-left: 130px;
    }

    h1 {
      position: relative;
      left: 800px;
    }
  </style>
</head>

<body>
  <h1>首页</h1>
  <div>
    <div class="box">

    </div>
  </div>
  <script src="https://code.jquery.com/jquery-3.7.1.js"></script>
  <script>
    var arr = [{
      id: 1,
      img: 'https://img.shetu66.com/2023/04/25/1682405982916194.png',
      name: '熊猫',
      pic: 50,
      num: 1,
      is: false
    }, {
      id: 2,
      img: 'https://tse1-mm.cn.bing.net/th/id/OIP-C.fDOzOyxJAxr2SY8uQwnPZQHaHa?pid=ImgDet&w=474&h=474&rs=1',
      name: '棕熊',
      pic: 20,
      num: 1,
      is: false
    }, {
      id: 3,
      img: 'https://tse1-mm.cn.bing.net/th/id/OIP-C.GMdR-v_6UdOlYuTU_MXJzAHaHa?pid=ImgDet&w=474&h=474&rs=1',
      name: '蓝熊',
      pic: 70,
      num: 1,
      is: false
    },]
    function apply() {
      $('.box').html('')
      arr.forEach(item => {
        $('.box').append(`
       <div class='boxs'>
         <img src="${item.img}"  onclick="tiao(${item.id})"><br>
         <span class="a">${item.name}</span>
         <span class="a">￥:${item.pic}</span>
       </div>
      `)
      })
    }
    apply()
    var obj = []
    function tiao(id) {
      var a = arr.find(item => item.id == id)
      obj.push(a)
      var b = JSON.stringify(obj)
      localStorage.setItem('data', b)
      location.assign('./2.28详情.html')
    }
  </script>
</body>

</html>